package up.android;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class Main extends ListActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ViewsListAdapter adapter = new ViewsListAdapter(getApplicationContext());
        setListAdapter(adapter);
		adapter.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				ViewListItem item = (ViewListItem)v.getTag();
				if(item.activity() != null)
				{
	   				Intent it = new Intent(Main.this,item.activity());
    				startActivity(it);
 				}
				else
				{
					Toast t = Toast.makeText(getApplicationContext(), item.toString(), Toast.LENGTH_SHORT);
					t.show();
				}
			}
		});

    
    }
}